import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
// import Layout from '../views/layout/Layout'

// import Bar from '../views/test/Bar.vue'
// import Foo from '../views/test/Foo.vue'

export const constantRouterMap = [
	// { path: '/404', component: () => import('@/views/404'), hidden: true },
	{
		path: '',
		name: 'IndexFirst',
		component: () => import('@/views/pages/Index')
	},
	{
		path: '/Index',
		name: 'Index',
		component: () => import('@/views/pages/Index')
	},
	{
		path: '/UserInfo',
		name: 'UserInfo',
		component: () => import('@/views/pages/UserInfo')
	},
	{
		path: '/WhereGo',
		name: 'WhereGo',
		component: () => import('@/views/pages/WhereGo')
	},
	{
		path: '/ECheng',
		name: 'ECheng',
		component: () => import('@/views/pages/ECheng')
	}, {
		path: '/OrderBook',
		name: 'OrderBook',
		component: () => import('@/views/pages/OrderBook')
	},
	{
		path: '/Register',
		name: 'Register',
		component: () => import('@/views/auth/Register')
	},
	{
		path: '/Login',
		name: 'Login',
		component: () => import('@/views/auth/Login')
	},

	// {
	// 	path: '*',
	// 	redirect: '/404',
	// 	hidden: true
	// }
]

export default new Router({
	// mode: 'history', //后端支持可开
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRouterMap
})
// 解决重复点击路由报错的BUG
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch((err) => err)
}
